//package com.guet.careapp.controller.rest.controller.service;
//
///**
// * Created by LXM on 2017/12/15.
// *
// * @author LXM
// * @version 1.0
// * @description 用于提供吃药提醒的类
// * @datetime 12:11
// */
//
//import com.guet.careapp.controller.rest.common.errorCode.Error;
//import com.guet.careapp.controller.rest.common.errorCode.ErrorCode;
//import com.guet.careapp.controller.rest.common.errorCode.ErrorCodeFactory;
//import com.guet.careapp.pojo.TUserGuardianInfo;
//import com.guet.careapp.pojo.TUserInfo;
//import com.guet.careapp.pojo.TUserUnderGuardiansInfo;
//import com.guet.careapp.pojo.rest.Introduction;
//import com.guet.careapp.service.*;
//import org.slf4j.LoggerFactory;
//import org.springframework.beans.factory.annotation.Autowired;
//import org.springframework.stereotype.Controller;
//
//import javax.ws.rs.Consumes;
//import javax.ws.rs.POST;
//import javax.ws.rs.Path;
//import javax.ws.rs.Produces;
//import javax.ws.rs.core.MediaType;
//import java.util.HashMap;
//import java.util.Map;
//
//@Controller
//@Path("/services/drug")
//public class TimeToEatDrug {
//
//    protected static final org.slf4j.Logger LOG = LoggerFactory.getLogger(TimeToEatDrug.class);
//
//    @Autowired
//    private IInstructionService instructionService;
//
//    @Autowired
//    private IUserGuardianInfoService guardianInfoService;
//
//    @Autowired
//    private IUserRelationService relationService;
//
//    @Autowired
//    private IUserUnderGuardiansInfoService underGuardiansInfoService;
//
//    @Autowired
//    private IPositionService positionService;
//
//    @Autowired
//    private IPushService pushService;
//
//    @Autowired
//    private IUserInfoService userInfoService;
//
//
//    @POST
//    @Produces(MediaType.APPLICATION_JSON)
//    @Consumes(MediaType.APPLICATION_JSON)
//    public ErrorCode alertOldsToEatDrug(Introduction introduction) {
//        Map<String, Object> map = new HashMap<>();
//        TUserGuardianInfo guardian;
//        TUserUnderGuardiansInfo underGuardians;
//        TUserInfo userInfo;
//        Integer g;
//        Integer ug;
//        //取出参数
//        try {
//            g = Integer.parseInt(introduction.getSendUid());
//            ug = Integer.parseInt(introduction.getReceiveUid());
//        } catch (Exception e) {
//            return ErrorCodeFactory.get(Error.TypeError);
//        }
//        //检查关系是否存在
//        boolean hasRelation = relationService.checkRelation(g, ug);
//        if (!hasRelation)
//            return ErrorCodeFactory.get(Error.Unkonwn);
//        //查找被监护人的设备id
//        userInfo = userInfoService.findById(ug);
//        String device_id = userInfo.getDeviceId();
//        //发送吃药的请求
//        Error e = pushService.PushTimeToEatMedicines(introduction, device_id);
//        return ErrorCodeFactory.get(e);
//
//    }
//}
